<template>
    <section class="authstr-list-box bgcFFF">
      <ul :style="{'height':ulH}" v-if="type != 3">
        <li v-for="(item,index) in data" :key="index" v-if="index < num">
          <div>
            <div class="left inline-block">
              <img class="inline-block" :src="item.pic" alt="">
              <div class="inline-block">
                <p class="color45454D fs17">{{item.name}}</p>
                <p class="color7A7B82 fs13">{{item.phone}}</p>
              </div>
            </div>
            <div class="left inline-block" v-if="type == 3">
              <p>{{item.name}}</p>
            </div>
            <div v-if="type == 1" class="right inline-block flr fs14 text-r">
              <span @click="handleRefuse(item)" class="refuse-btn inline-block color7A7B82">拒绝</span>
              <span @click="handleAgress(item)" class="agree-btn inline-block color45454D">同意</span>
            </div>
            <div v-if="type == 3" class="right inline-block flr fs14 text-r">
              <i class="del-search-record iconfont iconcha1" @click="handleDel(item)"></i>
            </div>
          </div>
        </li>
      </ul>

      <!--搜索记录-->
      <ul :style="{'height':ulH}" v-if="type == 3">
        <li class="liH1" v-for="(item,index) in data" :key="index" v-if="index < num">
          <div>
            <div class="left inline-block">
              <p>{{item.name}}</p>
            </div>
            <div class="right inline-block flr fs14 text-r" style="padding-top: 0;">
              <i class="del-search-record iconfont iconcha1" @click="handleDel(item)"></i>
            </div>
          </div>
        </li>
      </ul>

      <p class="show-more text-c color7A7B82 fs12" v-if="type == 1 && data.length > 2" @click="showMore"><span class="text-c">{{text}}</span></p>
    </section>
</template>

<script type="text/ecmascript-6">

  export default {
    data() {
      return {
        text:'显示全部',
        isShow: false,
        num: this.showNum ? this.showNum : this.data.length,
        ulH:0
      }
    },
    props:['data','type','showNum'],//data:数据；type：展示类型（1:待审核，2:已审核，3:搜索）;showNum:设置显示数量
    created(){
      if(this.type == 1){
        this.ulH = this.data.length > 1 ? '120px' : '60px'
      }else{
        this.ulH = 'auto'
      }

    },
    methods: {
      handleRefuse(item){
        this.$emit('handleRefuse',item)
      },
      handleAgress(item){
        this.$emit('handleAgress',item)
      },
      showMore(){
        this.isShow = !this.isShow;
        this.ulH = !this.isShow ? (this.data.length > 1 ? '120px' : '60px') : this.data.length * 60 +'px';
        if(this.isShow){
          this.text = '收起'
          this.num = this.data.length
        }else{
          setTimeout(() => {
            this.num = this.showNum
          }, 100)
          this.text = '显示全部'
        }

//        this.num = this.isShow ? this.data.length : this.showNum;
//        this.text = this.isShow ? '收起':'显示全部';
      },
      handleDel(item){
        this.$emit('hanleDel',item)
      }
    },
  }
</script>

<style scoped lang="scss">
  @import '../assets/css/base.scss';

  .authstr-list-box{
    width: 100%;
    height:auto;

    ul{
      width: 100%;
      transition: all .2s;

      .liH1{
        height: 40px !important;
      }



      li{
        height: 60px;
        width: 100%;
        padding:10px 15px 10px 20px;
        box-sizing: border-box;

        div{
          width: 100%;
          height: 100%;

          .left{
            width: 60%;

            img{
              width: 40px;
              height: 40px;
              border-radius: 50%;
              margin-right: 5px;
              vertical-align: bottom;
            }

            div{
              height: 100%;
              width: calc(100% - 50px);
            }
          }

          .right{
            width: 40%;
            padding-top: 7px;

            span{
              border-radius: 14px;
              padding: 4px 15px;
            }

            span.agree-btn{
              background-color: #EAEBF8;
            }

            .del-search-record{
              color: #B3B3B3;
            }
          }
        }
      }
    }

    .show-more{
      background: #fff;
      width: 100%;
      height: 32px;
      line-height: 32px;

      span{
        display: block;
        width: 100%;
        height: 100%;
        clear: both;
      }
    }
  }
</style>
